﻿using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.MediaCenter;
using Microsoft.MediaCenter.Hosting;
using Microsoft.MediaCenter.UI;

namespace ClipShowShell.Code
{
    public class MarkupLoader : ModelItem
    {
        private AddInHost host;
        private HistoryOrientedPageSession session;

        public MarkupLoader()
            : this(null, null)
        {
        }

        public AddInHost MyHost
        {
            get { return (host); }
        }

        public MarkupLoader(HistoryOrientedPageSession session, AddInHost host)
        {
            this.session = session;
            this.host = host;
        }

        public MediaCenterEnvironment MediaCenterEnvironment
        {
            get
            {
                if (host == null) return null;
                return host.MediaCenterEnvironment;
            }
        }

        public void Start()
        {
            Dictionary<string, object> properties = new Dictionary<string, object>();
            properties["Application"] = this;

            if (session != null)
            {
                session.GoToPage("resx://ClipShowShell/ClipShowShell.Resources/BrowserShell#Start", properties);
            }
            else
            {
                Debug.WriteLine("Start");
            }
        }
    }
}
